<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //混合继承
        // let father={
        //     name:'zhangsan',
        //     age:18,
        //     skill(){
        //         888
        //     }
        // }
        // let son={
        //     name:'wangwu',
        //     age:5
        // }
        // for(let key in father){
        //     son[key]=father[key]
        // }
        // console.log(son.skill);


        //原型继承
        function Animoul(name,sleep){
            this.name=name,
            this.sleep=function(){
                console.log(this.name + '正在睡觉')
            }
        }
        Animoul.prototype.eat=function(food){
            console.log(this.name + '正在吃:' + food);
            
        }
        //子类
        function Cat(){
            
        }
        Cat.prototype=new Animoul()
        Cat.prototype.name='黄思政'
        var cat=new Cat()
        console.log(cat.name);
        console.log(cat.sleep());
        console.log(cat.eat('辣条'));
    </script>
</body>
</html>